<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app {
            width: 500px;
            margin: 0 auto;
            background-color: orangered;
        }
    </style>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    function debounce(fn, wait = 500) {
        let timer = null
        return function (...args) {
            if (timer) {
                clearTimeout(timer)
            } else {
                timer = setTimeout(() => {
                    fn.apply(this,args)
                    timer = null
                }, wait)
            }
        }
    }
    document.onmousemove = debounce(function () {
        console.log(111);
    }, 500)
</script>

</html>